package com.esun.service.mq.rabbitmq.producer;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.esun.common.log.OperationLogEo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author John.xiao
 * @date 2021/10/11 14:42
 */
//@Component
@Slf4j
public class OperationLogProducer {
	@Resource
	AmqpTemplate amqpTemplate;

	public void sendLog(OperationLogEo operationLogEo){
		String context  = JSONObject.toJSONString(operationLogEo);
		log.info("sending operation log :{}", JSONObject.toJSONString(context, SerializerFeature.PrettyFormat));
		amqpTemplate.convertAndSend("operationLog",context);
	}
}
